//
// Created by tan on 22-8-20.
//

#include "GRow.h"
#include "rapidcsv.h"
#include "tools.h"

using namespace std;
using namespace rapidcsv;


GRow::GRow(string &strOrgGerber, string &lineNo, string &coords, string &blockNo, string &strNewGerber,
           string &netCoords, string &originalCoords, string &action, string &lineR) {
    this->strOrgGerber = strOrgGerber;
    this->lineNo = getNo(lineNo);
    this->coords = Tools::cell2arr(coords);
    this->blockNo = getBlockNo(blockNo);
    this->strNewGerber = strNewGerber;
    this->netCoords = netCoords;
    this->originalCoords = Tools::cell2arr(originalCoords);
    this->action = action;
    this->lineR = lineR;
    vector<double> _allPoints;
    _allPoints.insert(_allPoints.end(), this->originalCoords.begin(), this->originalCoords.end());
    _allPoints.insert(_allPoints.end(), this->coords.begin(), this->coords.end());
    this->allPointsOfLine = _allPoints;
}

int GRow::getBlockNo(string &orgBlockNo) {
    if (orgBlockNo.empty()) {
        return -1;
    }
    const regex &pat = regex(".*_([0-9]+)$");
    int _blockNo = getNo(orgBlockNo, pat);
    return _blockNo;
}
